package org.mk.script.core.caculate;

import org.mk.script.core.NonTerminal;
import org.mk.script.core.Num;

/**
 * 算子
 * @author Administrator
 *
 */
public  class AddTwoCalculate extends TwoCalculate{
	
	protected NonTerminal left;
	protected NonTerminal right;
	@Override
	/**
	 * 左右必须都是数字
	 */
	public NonTerminal execute() {
		NonTerminal leftNonTerminal = left.execute();
		String num1 = leftNonTerminal.getValue();
		NonTerminal rightNonTerminal = right.execute();
		String num2 = rightNonTerminal.getValue();
		Long result = Long.parseLong(num1) +  Long.parseLong(num2);
		return new Num(""+result);
	}
	
	
	
	
}
